package com.ruoyi.quartz.task;

import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.quartz.service.ISysJobLogService;
import com.ruoyi.quartz.service.ISysJobService;
import com.ruoyi.quartz.service.MediaServerService;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component("asherVideoRecordTask")
public class AsherVideoRecordTask {

    @Autowired
    private MediaServerService mediaServerService;

    @Autowired
    private ISysJobService sysJobService;

    @Autowired
    private RedisCache redisCache;

    public void startRecordTask(String mediaServerId, String mainId) throws SchedulerException {
//        mediaServerService.startRecord(mediaServerId, mainId);
//        Long startJobId = (Long)redisCache.getCacheObject(mediaServerId + "-" + mainId + "START_JOB");
//        sysJobService.deleteJobByIds(new Long[]{startJobId});

    }

    public void stopRecordTask(String mediaServerId, String mainId) throws SchedulerException {
        mediaServerService.stopRecord(mediaServerId, mainId);
        Long endJobId = (Long)redisCache.getCacheObject(mediaServerId + "-" + mainId + "END_JOB");
        sysJobService.deleteJobByIds(new Long[]{endJobId});
    }
}
